package com.emmy.love;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.emmy.loveview.LoveView;

import java.util.Calendar;
import java.util.Date;

public class MainActivity extends AppCompatActivity {

    private LoveView loveView;
    private Calendar calendar;

    private Date first = new Date(116,4,12);
    private Date second;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        loveView = findViewById(R.id.loveView);
        calendar = Calendar.getInstance();
        loveView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                second = new Date();
                long days = ((second.getTime()-first.getTime())/(60*60*1000*24));
                int intDay = (int)days;
                Toast.makeText(getBaseContext(), "在一起" + intDay +"天了呀！", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
